import { darken, lighten } from './colorHandle'
export const getFileUrl = (url) => {
  return url.replace('/src/', '../')
}

export const getFileSrc = (fileUrl) => {
  return new URL(fileUrl.replace('/src/', '../'), import.meta.url).href
}

function setPropertyPrimary(mode, i, color) {
  document.documentElement.style.setProperty(
    `--el-color-primary-${mode}-${i}`,
    lighten(color, i / 10)
  )
}
export const setTheme = (targetTheme) => {
  document.documentElement.style.setProperty('--el-color-primary', targetTheme)
  for (let i = 1; i <= 9; i++) {
    setPropertyPrimary('light', i, targetTheme)
  }
}
